import Vue from 'vue'
import Vuex from 'vuex'

import { getItem, setItem } from '@/utils/storage.js'

Vue.use(Vuex)

// this.$store === new Vuex.Store()
export default new Vuex.Store({
  state: {
    // 存储登录成功后返回的token
    user: getItem('tt_token')
  },
  mutations: {
    // 获取token
    initUser (state, data) {
      state.user = data
      // 本地存储
      setItem('tt_token', data)
    }
  },
  actions: {
  },
  modules: {
  }
})
